<script src="//unpkg.com/layui@2.11.2/dist/layui.js"></script>
<div class="layui-row layui-col-space20">
  <!-- 类型数量卡片 -->
  <div class="layui-col-sm6">
    <div class="layui-card stat-card layui-bg-blue">
      <div class="layui-card-body">
        <div class="stat-icon layui-icon layui-icon-template-1"></div>
        <div class="stat-info">
          <p class="stat-label">文章类型数量</p>
          <p class="stat-value" id="type-count"></p>
        </div>
      </div>
    </div>
  </div>

  <!-- 文章总数卡片 -->
  <div class="layui-col-sm6">
    <div class="layui-card stat-card layui-bg-orange">
      <div class="layui-card-body">
        <div class="stat-icon layui-icon layui-icon-read"></div>
        <div class="stat-info">
          <p class="stat-label">文章总数</p>
          <p class="stat-value" id="article-count"></p>
        </div>
      </div>
    </div>
  </div>
</div>

<style>
    .layui-row{
        margin-top: 100px;
        margin-left: 200px;
    }
.stat-card {
  color: #fff;
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.stat-card:hover {
  transform: translateY(-2px);
}
.stat-card .layui-card-body {
  display: flex;
  align-items: center;
  padding: 24px;
}
.stat-icon {
  font-size: 40px;
  margin-right: 20px;
}
.stat-info .stat-label {
  font-size: 16px;
  margin-bottom: 8px;
}
.stat-info .stat-value {
  font-size: 28px;
  font-weight: bold;
}
.layui-bg-blue {
  background: linear-gradient(135deg, #3a8ee6, #70c8ff);
}
.layui-bg-orange {
  background: linear-gradient(135deg, #f6a263, #fecd76);
}
</style>

<script>
layui.use(['layer'], function(){
  const $ = layui.$;

  // 模拟获取数据
  const typeData = JSON.parse(localStorage.getItem('articleCategories') || '[]');
  const articleData = JSON.parse(localStorage.getItem('articles') || '[]');
  console.log(articleData);
    
  // 数字动画
  function animateCount(id, end) {
    let current = 0;
    const step = Math.ceil(end / 600);
    const interval = setInterval(() => {
      current += step;
      if (current >= end) {
        current = end;
        clearInterval(interval);
      }
      document.getElementById(id).innerText = current;
    }, 100);
  }

  animateCount('type-count', typeData.length);
  animateCount('article-count', articleData.length);
});
</script>
